package com.hzit.loan.pay.controller;

import com.hzit.loan.pay.commonApi.resp.PayNotifyData;
import com.hzit.loan.pay.commonApi.resp.RespVo;
import com.hzit.loan.pay.commonApi.resp.TaskTradeQueryRespData;
import com.hzit.loan.pay.service.IPaySerialService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 定时任务-需要的接口
 */
@RestController
@RequestMapping("/task")
public class TaskController {

    private Logger logger = LoggerFactory.getLogger(TaskController.class);

    @Autowired
    private IPaySerialService iPaySerialService;


    /**
     * 获取支付流水表中，状态为1和2的数据（未支付，支付中）
     * @param payChannel
     */
    @RequestMapping("/queyTrading")
    public RespVo<List<TaskTradeQueryRespData> > queyTradingList(@RequestParam("payChannel") String payChannel){

        RespVo<List<TaskTradeQueryRespData> > respVo = new RespVo<>();
        List<TaskTradeQueryRespData>  dataList =iPaySerialService.queryByPayChannel(payChannel);
        respVo.setCode(0);
        respVo.setMsg("查询成功");
        respVo.setData(dataList);
        return respVo;
    }


    /**
     * 更新支付流水状态
     */
    @RequestMapping("/updateTrading")
    public String updateTradingList(@RequestBody PayNotifyData payNotifyData){
        //TODO 日志
        String rlt = iPaySerialService.updatePaySerial(payNotifyData);
        //返回 日志
        return rlt;
    }



}
